<script type="text/javascript">
//    //日期组件
//    $(function() {
//        $('.doc-datepicker').datepicker().
//        on('changeDate.datepicker.amui', function(event) {
//            console.log(event.date);
//        });
//    });
    /**
     * 教育背景
     * */
    //教育背景增加
    function addEdu(){
        $('#eduAdd').modal();
    }
    //教育背景增加设置
    function setAddEdu(){
        var uid = $('#uid').val();
        var eduBgStart = $('#eduAdd #eduBgStart').val();
        var eduBgEnd = $('#eduAdd #eduBgEnd').val();
        var eduBgSchool = $('#eduAdd #eduBgSchool').val();
        var eduBgMajor = $('#eduAdd #eduBgMajor').val();
        var eduBgAward = $('#eduAdd #eduBgAward').val();
        if (!eduBgStart.match(regDate)) {
            $('#popWorkEditMsg').html('起始时间未填选或格式错误！');
            return
        }
        if (!eduBgEnd.match(regDate)) {
            $('#popWorkEditMsg').html('结束时间未填选或格式错误！');
            return
        }
        if (!eduBgSchool || !eduBgMajor || !eduBgAward) {
            $('#popWorkEditMsg').html('学校、专业或奖项未填选！');
            return
        }
        var formData = {
            uid:uid,
            oper:'add',
            key:0,
            eduBgStart:eduBgStart,
            eduBgEnd:eduBgEnd,
            eduBgSchool:eduBgSchool,
            eduBgMajor:eduBgMajor,
            eduBgAward:eduBgAward
        };
        $.ajaxSetup({
            headers: { 'X-CSRF-TOKEN': $('#_token').val() }
        });
        $.ajax({
            type:'post',
            dataType:'json',
            url:getPrefix() + '/edu-set',
            data:formData,
            success:function(res){
                //console.log(res); return
                if (res.code!=0) {
                    console.log(res);
                    $('#popEduAddMsg').html(res.msg);
                    alert(res.msg); return
                }
                $('#popEduAddMsg').html('更新成功，马上跳转！');
                setTimeout(function(){
                    window.location.href = '';
                },1000*3);
            },
            error:function(){
                console.log('操作失败！');
            }
        });
    }
    //教育背景编辑
    function modifyEdu(eduId){
        var eduBgStart = $('#eduBgStart'+eduId).val();
        var eduBgEnd = $('#eduBgEnd'+eduId).val();
        var eduBgSchool = $('#eduBgSchool'+eduId).val();
        var eduBgMajor = $('#eduBgMajor'+eduId).val();
        var eduBgAward = $('#eduBgAward'+eduId).val();
        $('#eduModify #key')[0].value = eduId;
        $('#eduModify #eduBgStart')[0].value = eduBgStart;
        $('#eduModify #eduBgEnd')[0].value = eduBgEnd;
        $('#eduModify #eduBgSchool')[0].value = eduBgSchool;
        $('#eduModify #eduBgMajor')[0].value = eduBgMajor;
        $('#eduModify #eduBgAward')[0].value = eduBgAward;
        $('#eduModify').modal();
    }
    //教育背景更新
    function updateEdu(){
        var uid = $('#uid').val();
        var key = $('#eduModify #key').val();
        var eduBgStart = $('#eduModify #eduBgStart').val();
        var eduBgEnd = $('#eduModify #eduBgEnd').val();
        var eduBgSchool = $('#eduModify #eduBgSchool').val();
        var eduBgMajor = $('#eduModify #eduBgMajor').val();
        var eduBgAward = $('#eduModify #eduBgAward').val();
        var regDate = /^(\d{1,4})(-)(\d{1,2})\2(\d{1,2})$/;
        if (!eduBgStart.match(regDate)) {
//                alert('起始时间未填选或格式错误！');
            $('#popWorkEditMsg').html('起始时间未填选或格式错误！');
            return
        }
        if (!eduBgEnd.match(regDate)) {
//                alert('结束时间未填选或格式错误！');
            $('#popWorkEditMsg').html('结束时间未填选或格式错误！');
            return
        }
        if (!eduBgSchool || !eduBgMajor || !eduBgAward) {
//                alert('学校、专业或奖项未填选！');
            $('#popWorkEditMsg').html('学校、专业或奖项未填选！');
            return
        }
        var formData = {
            uid:uid,
            oper:'modify',
            key:key,
            eduBgStart:eduBgStart,
            eduBgEnd:eduBgEnd,
            eduBgSchool:eduBgSchool,
            eduBgMajor:eduBgMajor,
            eduBgAward:eduBgAward
        };
//            console.log(formData); return
        $.ajaxSetup({
            headers: { 'X-CSRF-TOKEN': $('#_token').val() }
        });
        $.ajax({
            type:'post',
            dataType:'json',
            url:getPrefix() + '/edu-set',
            data:formData,
            success:function(res){
                //console.log(res); return
                if (res.code!=0) {
                    console.log(res);
                    $('#popEduEditMsg').html(res.msg);
                    alert(res.msg); return
                }
                $('#popEduEditMsg').html('更新成功，马上跳转！');
                setTimeout(function(){
                    window.location.href = '';
                },1000*2);
            },
            error:function(){
                console.log('操作失败！');
            }
        });
    }
    /**
     * 工作经历
     * */
    //工作经历增加
    function addWork(){
        $('#workAdd').modal();
    }
    //工作经历增加设置
    function setAddWork(){
        var uid = $('#uid').val();
        var workStart = $('#workAdd #workStart').val();
        var workEnd = $('#workAdd #workEnd').val();
        var workComName = $('#workAdd #workComName').val();
        var workJob = $('#workAdd #workJob').val();
        var workLeave = $('#workAdd #workLeave').val();
        var regDate = /^(\d{1,4})(-)(\d{1,2})\2(\d{1,2})$/;
        if (!workStart.match(regDate)) {
            $('#popWorkEditMsg').html('起始时间未填选或格式错误！');
            return
        }
        if (!workEnd.match(regDate)) {
            $('#popWorkEditMsg').html('结束时间未填选或格式错误！');
            return
        }
        if (!workComName || !workJob || !workLeave) {
            $('#popWorkEditMsg').html('公司名称、岗位或离职原因未填选！');
            return
        }
        var formData = {
            uid:uid,
            oper:'add',
            key:0,
            workStart:workStart,
            workEnd:workEnd,
            workComName:workComName,
            workJob:workJob,
            workLeave:workLeave
        };
//            console.log(formData); return
        $.ajaxSetup({
            headers: { 'X-CSRF-TOKEN': $('#_token').val() }
        });
        $.ajax({
            type:'post',
            dataType:'json',
            url:getPrefix() + '/work-set',
            data:formData,
            success:function(res){
                //console.log(res); return
                if (res.code!=0) {
                    console.log(res);
                    $('#popWorkAddMsg').html(res.msg);
                    alert(res.msg); return
                }
                $('#popWorkAddMsg').html('更新成功，马上跳转！');
                setTimeout(function(){
                    window.location.href = '';
                },1000*3);
            },
            error:function(){
                console.log('操作失败！');
            }
        });
    }
    //工作经历编辑
    function modifyWork(workId){
        var workStart = $('#workStart'+workId).val();
        var workEnd = $('#workEnd'+workId).val();
        var workComName = $('#workComName'+workId).val();
        var workJob = $('#workJob'+workId).val();
        var workLeave = $('#workLeave'+workId).val();
        $('#workModify #key')[0].value = workId;
        $('#workModify #workStart')[0].value = workStart;
        $('#workModify #workEnd')[0].value = workEnd;
        $('#workModify #workComName')[0].value = workComName;
        $('#workModify #workJob')[0].value = workJob;
        $('#workModify #workLeave')[0].value = workLeave;
        $('#workModify').modal();
    }
    //工作经历更新
    function updateWork(){
        var uid = $('#uid').val();
        var key = $('#workModify #key').val();
        var workStart = $('#workModify #workStart').val();
        var workEnd = $('#workModify #workEnd').val();
        var workComName = $('#workModify #workComName').val();
        var workJob = $('#workModify #workJob').val();
        var workLeave = $('#workModify #workLeave').val();
        var regDate = /^(\d{1,4})(-)(\d{1,2})\2(\d{1,2})$/;
        if (!workStart.match(regDate)) {
//                alert('起始时间未填选或格式错误！');
            $('#popWorkEditMsg').html('起始时间未填选或格式错误！');
            return
        }
        if (!workEnd.match(regDate)) {
//                alert('结束时间未填选或格式错误！');
            $('#popWorkEditMsg').html('结束时间未填选或格式错误！');
            return
        }
        if (!workComName || !workJob || !workLeave) {
//                alert('公司名称、岗位或离职原因未填选！');
            $('#popWorkEditMsg').html('公司名称、岗位或离职原因未填选！');
            return
        }
        var formData = {
            uid:uid,
            oper:'modify',
            key:key,
            workStart:workStart,
            workEnd:workEnd,
            workComName:workComName,
            workJob:workJob,
            workLeave:workLeave
        };
//            console.log(formData); return
        $.ajaxSetup({
            headers: { 'X-CSRF-TOKEN': $('#_token').val() }
        });
        $.ajax({
            type:'post',
            dataType:'json',
            url:getPrefix() + '/work-set',
            data:formData,
            success:function(res){
                //console.log(res); return
                if (res.code!=0) {
                    console.log(res);
                    $('#popWorkEditMsg').html(res.msg);
                    alert(res.msg); return
                }
                $('#popWorkEditMsg').html('更新成功，马上跳转！');
                setTimeout(function(){
                    window.location.href = '';
                },1000*2);
            },
            error:function(){
                console.log('操作失败！');
            }
        });
    }
    /**
     * 家庭成员
     * */
    //家庭成员增加
    function addFamily(){
        $('#familyAdd').modal();
    }
    //家庭成员增加设置
    function setAddFamily(){
        var uid = $('#uid').val();
        var familyName = $('#familyAdd #familyName').val();
        var familyCall = $('#familyAdd #familyCall').val();
        var familyCom = $('#familyAdd #familyCom').val();
        var familyContact = $('#familyAdd #familyContact').val();
        if (!familyName || !familyCall || !familyCom || !familyContact) {
            $('#popFamilyEditMsg').html('成员姓名、称谓、公司或联系方式未填选！');
            return
        }
        var formData = {
            uid:uid,
            oper:'add',
            key:0,
            familyName:familyName,
            familyCall:familyCall,
            familyCom:familyCom,
            familyContact:familyContact
        };
        $.ajaxSetup({
            headers: { 'X-CSRF-TOKEN': $('#_token').val() }
        });
        $.ajax({
            type:'post',
            dataType:'json',
            url:getPrefix() + '/family-set',
            data:formData,
            success:function(res){
                //console.log(res); return
                if (res.code!=0) {
                    console.log(res);
                    $('#popFamilyAddMsg').html(res.msg);
                    alert(res.msg); return
                }
                $('#popFamilyAddMsg').html('更新成功，马上跳转！');
                setTimeout(function(){
                    window.location.href = '';
                },1000*3);
            },
            error:function(){
                console.log('操作失败！');
            }
        });
    }
    //家庭成员编辑
    function modifyFamily(familyId){
        var familyName = $('#familyName'+familyId).val();
        var familyCall = $('#familyCall'+familyId).val();
        var familyCom = $('#familyCom'+familyId).val();
        var familyContact = $('#familyContact'+familyId).val();
        $('#familyModify #key')[0].value = familyId;
        $('#familyModify #familyName')[0].value = familyName;
        $('#familyModify #familyCall')[0].value = familyCall;
        $('#familyModify #familyCom')[0].value = familyCom;
        $('#familyModify #familyContact')[0].value = familyContact;
        $('#familyModify').modal();
    }
    //家庭成员更新
    function updateFamily(){
        var uid = $('#uid').val();
        var key = $('#familyModify #key').val();
        var familyName = $('#familyModify #familyName').val();
        var familyCall = $('#familyModify #familyCall').val();
        var familyCom = $('#familyModify #familyCom').val();
        var familyContact = $('#familyModify #familyContact').val();
        if (!key || !familyName || !familyCall ||
                !familyCom || !familyContact) {
            $('#popFamilyEditMsg').html('成员姓名、称谓、公司或联系方式未填选！');
            return
        }
        var formData = {
            uid:uid,
            oper:'modify',
            key:key,
            familyName:familyName,
            familyCall:familyCall,
            familyCom:familyCom,
            familyContact:familyContact
        };
        $.ajaxSetup({
            headers: { 'X-CSRF-TOKEN': $('#_token').val() }
        });
        $.ajax({
            type:'post',
            dataType:'json',
            url:getPrefix() + '/family-set',
            data:formData,
            success:function(res){
                //console.log(res); return
                if (res.code!=0) {
                    console.log(res);
                    $('#popFamilyAddMsg').html(res.msg);
                    alert(res.msg); return
                }
                $('#popFamilyAddMsg').html('更新成功，马上跳转！');
                setTimeout(function(){
                    window.location.href = '';
                },1000*3);
            },
            error:function(){
                console.log('操作失败！');
            }
        });
    }
    /**
     * 个人评价
     * */
    //个人评价编辑
    function modifyComment(){
        var comFeature = $('#comFeature').val();
        var comSkill = $('#comSkill').val();
        var comHobby = $('#comHobby').val();
        var comExpect = $('#comExpect').val();
        var businessRadioInput = $('#businessRadioInput').val();
        var skillRadioInput = $('#skillRadioInput').val();
        $('#commentModify #comFeature')[0].value = comFeature;
        $('#commentModify #comSkill')[0].value = comSkill;
        $('#commentModify #comHobby')[0].value = comHobby;
        $('#commentModify #comExpect')[0].value = comExpect;
//            $('#commentModify #businessRadioInput')[0].value = businessRadioInput;
//            $('#commentModify #skillRadioInput')[0].value = skillRadioInput;
        //业务、技能
        var formData = {
        };
        $.ajaxSetup({
            headers: { 'X-CSRF-TOKEN': $('#_token').val() }
        });
        $.ajax({
            type:'post',
            dataType:'json',
            url:getPrefix() + '/checks',
            data:formData,
            success:function(res){
                //console.log(res); return
                if (res.code!=0) {
                    console.log(res);
                    alert(res.msg); return
                }
                var resJobTypes = res.data.jobTypes;
                var resSkills = res.data.skills;
                console.log(resJobTypes,resSkills);
                var i, i2, h = '', h2 = '';
                for (i=0;i<resJobTypes.length;i++) {
                    h += '<option value="'+resJobTypes[i].id+'" ';
                    if (businessRadioInput==resJobTypes[i].id) {
                        h += 'selected';
                    }
                    h += '>';
                    h += resJobTypes[i].name;
                    h += '</option>';
                }
                for (i2=0;i2<resSkills.length;i2++) {
                    h2 += '<option value="'+resSkills[i2].id+'" ';
                    if (skillRadioInput==resSkills[i2].id) {
                        h2 += 'selected';
                    }
                    h2 += '>';
                    h2 += resSkills[i2].name;
                    h2 += '</option>';
                }
                $('#jobType').html(h);
                $('#skill').html(h2);
            },
            error:function(){
                console.log('操作失败！');
            }
        });
        $('#commentModify').modal();
    }
    //个人评价更新
    function updateComment(){
        var uid = $('#uid').val();
        var comFeature = $('#commentModify #comFeature').val();
        var comSkill = $('#commentModify #comSkill').val();
        var comHobby = $('#commentModify #comHobby').val();
        var comExpect = $('#commentModify #comExpect').val();
//            var businessRadioInput = $('#businessRadioInput').val();
//            var skillRadioInput = $('#skillRadioInput').val();
        var businessRadioInput = $('#jobType').val();
        var skillRadioInput = $('#skill').val();
        if (!comFeature || !comSkill || !comHobby || !comExpect
                || !businessRadioInput || !skillRadioInput) {
            $('#popCommentEditMsg').html('优势、技能、爱好、期待、业务需求或技术等级未填选！');
            return
        }
        var formData = {
            uid:uid,
            comFeature:comFeature,
            comSkill:comSkill,
            comHobby:comHobby,
            comExpect:comExpect,
            businessRadioInput:businessRadioInput,
            skillRadioInput:skillRadioInput
        };
        $.ajaxSetup({
            headers: { 'X-CSRF-TOKEN': $('#_token').val() }
        });
        $.ajax({
            type:'post',
            dataType:'json',
            url:getPrefix() + '/comment-set',
            data:formData,
            success:function(res){
                //console.log(res); return
                if (res.code!=0) {
                    console.log(res);
                    $('#popCommentEditMsg').html(res.msg);
                    alert(res.msg); return
                }
                $('#popCommentAddMsg').html('更新成功，马上跳转！');
                setTimeout(function(){
                    window.location.href = '';
                },1000*3);
            },
            error:function(){
                console.log('操作失败！');
            }
        });
    }
    /**
     * 工厂求职意向
     * */
    //工厂求职意向编辑
    function modifyFacWill(){
        var uid = $('#uid').val();
        var formData = {
            uid:uid
        };
        $.ajaxSetup({
            headers: { 'X-CSRF-TOKEN': $('#_token').val() }
        });
        $.ajax({
            type:'post',
            dataType:'json',
            url:getPrefix() + '/fac-will',
            data:formData,
            success:function(res){
                //console.log(res); return
                if (res.code!=0) {
                    console.log(res);
                    alert(res.msg); return
                }
                console.log(res.data);
                var resFabric = res.data.fabricStr;
                var resTech = res.data.techStr;
                var resSkill = res.data.skillStr;
                $('#fabricDiv').html(resFabric);
                $('#techDiv').html(resTech);
                $('#skillDiv').html(resSkill);
                $('#facWillModify').modal();
            },
            error:function(){
                console.log('操作失败！');
            }
        });
    }
    //工厂求职意向，面料设置
    function setFabric(fid){
        var v = $('#fabricId'+fid).val();
        if (v==0) {
            $('#fabricId'+fid)[0].value = 1;
        } else {
            $('#fabricId'+fid)[0].value = 0;
        }
    }
    //工厂求职意向，技能设置
    function setSkill(sid){
        var v = $('#skillId'+sid).val();
        if (v==0) {
            $('#skillId'+sid)[0].value = 1;
        } else {
            $('#skillId'+sid)[0].value = 0;
        }
    }
    //工厂求职意向更新
    function updateFacWill(){
        var uid = $('#uid').val();
        var fabricCount = $('#fabricCount').val();
        var skillCount = $('#skillCount').val();
        var i, i2,
                fabricArr = new Array(),
                skillArr = new Array();
        for (i=0;i<fabricCount;i++) {
            fabricArr[i] = $('#fabricId'+i).val();
        }
        var techSel = $('#techSel').val();
        for (i2=0;i2<skillCount;i2++) {
            skillArr[i2] = $('#skillId'+i2).val();
        }
        var formData = {
            uid:uid,
            fabrics:fabricArr,
            techSel:techSel,
            skills:skillArr
        };
        $.ajaxSetup({
            headers: { 'X-CSRF-TOKEN': $('#_token').val() }
        });
        $.ajax({
            type:'post',
            dataType:'json',
            url:getPrefix() + '/fac-will-set',
            data:formData,
            success:function(res){
                //console.log(res); return
                if (res.code!=0) {
                    console.log(res);
                    alert(res.msg);
                    return
                }
                console.log(res.data);
                $('#popFacWillEditMsg').html('更新成功！');
                setTimeout(function(){
                    window.location.href = '';
                },1000*3);
            },
            error:function(){
                console.log('操作失败！');
            }
        });
    }
    /**
     * 公司求职意向
     * */
    //公司求职意向编辑
    function modifyComWill(){
        var uid = $('#uid').val();
        var address = $('#address').val();
        $('#addressStr').html(address);
        var formData = {
            uid:uid
        };
        $.ajaxSetup({
            headers: { 'X-CSRF-TOKEN': $('#_token').val() }
        });
        $.ajax({
            type:'post',
            dataType:'json',
            url:getPrefix() + '/com-will',
            data:formData,
            success:function(res){
                //console.log(res); return
                if (res.code!=0) {
                    console.log(res);
                    alert(res.msg); return
                }
//                console.log(res.data);
                var address = res.data.addressHtml;
                var module = res.data.moduleHtml;
                var job = res.data.jobHtml;
                var salary = res.data.salaryHtml;
                var work = res.data.workHtml;
                var industry = res.data.industryHtml;
                var jobTime = res.data.jobTimeHtml;
                var tag = res.data.tagHtml;
                $('#addressDiv').html(address);
                $('#jobModuleDiv').html(module);
                $('#jobDiv').html(job);
                $('#salaryDiv').html(salary);
                $('#workTypeDiv').html(work);
                $('#industryDiv').html(industry);
                $('#jobTimeDiv').html(jobTime);
                $('#tagDiv').html(tag);
                $('#comWillModify').modal();
            },
            error:function(){
                console.log('操作失败！');
            }
        });
    }
    //通过省，获取市
    function getCityList(p){
        var formData = {
            pid:p
        };
        $.ajax({
            type:'post',
            url:'/api/home/locate/city',
            data:formData,
            success:function(res){
                //console.log(res);
                if (res.code!=0) {
                    console.log(res);
                    return
                }
                var resData = res.data;
                var i, h = '';
                for (i=0;i<resData.length;i++) {
                    h += '<option value="'+resData[i].id+'">';
                    h += resData[i].name;
                    h += '</option>';
                }
                console.log(resData,h);
                $('#city').html(h);
            },
            error:function(){
                console.log('操作失败！');
            }
        });
    }
    //通过市，获取区
    function getAreaList(c){
        var formData = {
            pid:c
        };
        $.ajax({
            type:'post',
            url:'/api/home/locate/region',
            data:formData,
            success:function(res){
                //console.log(res);
                if (res.code!=0) {
                    console.log(res);
                    return
                }
                var resData = res.data;
                var i, h = '';
                for (i=0;i<resData.length;i++) {
                    h += '<option value="'+resData[i].id+'">';
                    h += resData[i].name;
                    h += '</option>';
                }
//                console.log(resData,h);
                $('#area').html(h);
            },
            error:function(){
                console.log('操作失败！');
            }
        });
    }
    //公司求职意向更新
    function updateComWill(){
        var uid = $('#uid').val();
        var area = $('#area').val();
        var module = $('#module').val();
        var job = $('#job').val();
        var salary = $('#salary').val();
        var work = $('#work').val();
        var industry = $('#industry').val();
        var jobTime = $('#jobTime').val();
        var tag = $('#tag').val();
        var formData = {
            uid:uid,
            area:area,
            module:module,
            job:job,
            salary:salary,
            work:work,
            industry:industry,
            jobTime:jobTime,
            tag:tag
        };
        $.ajax({
            type:'post',
            url:getPrefix() + '/com-will-set',
            data:formData,
            success:function(res){
                //console.log(res);
                if (res.code!=0) {
                    console.log(res);
                    alert(res.msg);
                    return
                }
                console.log(res.data);
                $('#popComWillEditMsg').html('更新成功！');
                setTimeout(function(){
                    window.location.href = '';
                },1000*3);
            },
            error:function(){
                console.log('操作失败！');
            }
        });
    }
    //员工认证编辑
    function modifyFile(fileId){
        var fileKeyArr = [
                '', 'selfs', 'idcards', 'byzs', 'awards', 'marrys', 'drives'
        ];
        var fileNameArr = [
                '', '本人照片', '身份证照片', '毕业证', '奖状', '结婚证', '驾驶证'
        ];
        var fileKey = fileKeyArr[fileId];
        var fileName = fileNameArr[fileId];
        $('input[name="fileId"]')[0].value = fileId;
        $('input[name="fileKey"]')[0].value = fileKey;
        $('#fileName')[0].value = fileName;
        $('#fileModify').modal();
    }
    //员工认证更新
    //请求地址
    function getPrefix(){
        return '/mcadmin/basic/member/staff/option';
    }
</script>